/*
 * $Id: TaskClassMapDAO.java,v 1.8 2009/07/24 18:27:43 oliver Exp $
 *
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 *
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */

package com.ge.healthcare.autosc.common.database.dao;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;

import org.springmodules.cache.annotations.Cacheable;

import com.ge.healthcare.autosc.common.ASCLogger;
import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.CfgTaskClassMap;

public class TaskClassMapDAO extends BaseDAO implements ITaskClassMapDAO {

	/**
	 * Eclipse generated
	 */
	private static final long serialVersionUID = -6491496978025850041L;

	public TaskClassMapDAO() {
		super(CfgTaskClassMap.TABLE_NAME);
	}

	@Cacheable(modelId = "CfgTaskClassMapCacheModel")
	public CfgTaskClassMap getTaskClassMapByID(Long taskClassMapId) {
		Object taskClassMap = findObjectByID(
				CfgTaskClassMap.COL_TASK_CLASS_MAP_ID, taskClassMapId);
		if (!ASCUtil.isNullOrEmptyObject(taskClassMap)) {
			return (CfgTaskClassMap) taskClassMap;
		}
		return null;
	}

	@Cacheable(modelId = "CfgTaskClassMapCacheModel")
	public Hashtable<String, CfgTaskClassMap> getTaskTypeClassMapHash() {
		Hashtable<String, CfgTaskClassMap> taskClassMapHash = new Hashtable<String, CfgTaskClassMap>();

		String queryString = "from " + CfgTaskClassMap.TABLE_NAME;
		ASCLogger.debug(this.getClass(), "getAllTaskClassMap",
				new StringBuffer().append(queryString));
		List<?> taskClassMapList = getHibernateTemplate().find(queryString);
		if (!ASCUtil.isNullOrEmptyObject(taskClassMapList)) {
			Iterator<?> iter = taskClassMapList.iterator();
			while (iter.hasNext()) {
				CfgTaskClassMap taskClassMap = (CfgTaskClassMap) iter.next();
				taskClassMapHash.put(taskClassMap.getTaskTypeName(),
						taskClassMap);
			}
		}
		return taskClassMapHash;
	}

	public void save(Object pojo) {
		super.save(pojo);
	}

	public void saveAlways(Object pojo) {
		super.save(pojo);
	}

	public void deleteByID(Object pojo) {
		super.deleteByID(pojo);
	}

	public void refresh(Object pojo) {
		super.refresh(pojo);
	}
}
